import type { User } from "@/api/user";

// utils/auth.ts
const KEY = 'furkid';

export function saveUser(u: User) {
  localStorage.setItem(KEY, JSON.stringify(u));
}

export function getUser(): User | null {
  const s = localStorage.getItem(KEY);
  return s ? (JSON.parse(s) as User) : null;
}

export function getToken(): string | null {
  return getUser()?.token ?? null;
}

export function clearUser() {
  localStorage.removeItem(KEY);
}

